const textFormat = (dataSets, textType ='') => {
  const { source, type, dimensions = undefined, sourceMap = {} } = dataSets;
  let dataValue = '';
  let [key] = Object.keys(sourceMap).length > 0 ? Object.keys(sourceMap) : [''];
  if (type === 'STATIC') {
    dataValue = source[0]?.value;
  } else {
    //iot组件取度量值
    dataValue = source && source.length ? textType==='iot' ?  source[0][dimensions?.yAxis] || source[0][key] :  source[0][dimensions?.xAxis] : '';
  }
  return {
    formatData: [
      {
        value: dataValue,
        name: dimensions?.yAxis || '',
        date: source[0]?.ts ||''
      },
    ],
      dimensions,
  };
};

export { textFormat };
